const ip = require('../utils/ipUtils')
const mysql = require('../db/mysql')
const searchDao = require('../sql/searchDao')

const url = ip.base + '/swiper/file/';

// 搜索
exports.index = async (req,res)=>{
    try {
        let num = (req.query.currentPage-1)*req.query.count||0;
        let count = +req.query.count||10;
        let row = await mysql(searchDao.selectAll, [req.query.keyword, num, count]);
        let total = await mysql(searchDao.total, [req.query.keyword, req.query.keyword, req.query.keyword, req.query.keyword])
        res.success({
            data:row,
            total: total[0].total
        });
    }catch (e) {
        console.log(e)
        res.status(500).fail('服务器错误')
    }
}
